From: Claudio Cambra Date: Tue, 11 Mar 2025 07:31:46 +0000 (+0800) Subject: gui: Expose if there are any configured sync folders in systray class to QML X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~1^2~17^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=5e71d6c02630fadb20391281b500b91be8564ac5;p=nextcloud-desktop.git gui: Expose if there are any configured sync folders in systray class to QML Signed-off-by: Claudio Cambra --- diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index bcf683658..6837073ce 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -109,6 +109,9 @@ Systray::Systray() connect(AccountManager::instance(), &AccountManager::accountAdded, this, [this]{ showWindow(WindowPosition::Center); }); #endif + + connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotSyncFoldersChanged); + slotSyncFoldersChanged(FolderMan::instance()->map()); } void Systray::create() @@ -490,6 +493,14 @@ void Systray::slotPauseAllFolders() setPauseOnAllFoldersHelper(true); } +void Systray::slotSyncFoldersChanged(const OCC::Folder::Map &folderMap) +{ + if (const auto currentAnySyncFolders = !folderMap.isEmpty(); currentAnySyncFolders != _anySyncFolders) { + _anySyncFolders = currentAnySyncFolders; + emit anySyncFoldersChanged(); + } +} + void Systray::setPauseOnAllFoldersHelper(bool pause) { // For some reason we get the raw pointer from Folder::accountState() @@ -610,6 +621,11 @@ void Systray::setSyncIsPaused(const bool syncIsPaused) emit syncIsPausedChanged(); } +bool Systray::anySyncFolders() const +{ + return _anySyncFolders; +} + /********************************************************************************************/ /* Helper functions for cross-platform tray icon position and taskbar orientation detection */ /********************************************************************************************/ diff --git a/src/gui/systray.h b/src/gui/systray.h index db2e3d7b9..6e18a596c 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -69,6 +69,7 @@ class Systray : public QSystemTrayIcon Q_PROPERTY(QString windowTitle READ windowTitle CONSTANT) Q_PROPERTY(bool useNormalWindow READ useNormalWindow CONSTANT) Q_PROPERTY(bool syncIsPaused READ syncIsPaused WRITE setSyncIsPaused NOTIFY syncIsPausedChanged) + Q_PROPERTY(bool anySyncFolders READ anySyncFolders NOTIFY anySyncFoldersChanged) Q_PROPERTY(bool isOpen READ isOpen WRITE setIsOpen NOTIFY isOpenChanged) Q_PROPERTY(bool enableAddAccount READ enableAddAccount CONSTANT) @@ -92,6 +93,7 @@ public: Q_REQUIRED_RESULT bool useNormalWindow() const; Q_REQUIRED_RESULT bool syncIsPaused() const; + Q_REQUIRED_RESULT bool anySyncFolders() const; Q_REQUIRED_RESULT bool isOpen() const; [[nodiscard]] bool enableAddAccount() const; @@ -113,6 +115,7 @@ signals: void showErrorMessageDialog(const QString &error); void syncIsPausedChanged(); + void anySyncFoldersChanged(); void isOpenChanged(); void hideSettingsDialog(); @@ -158,6 +161,7 @@ private slots: void slotUpdateSyncPausedState(); void slotUnpauseAllFolders(); void slotPauseAllFolders(); + void slotSyncFoldersChanged(const OCC::Folder::Map &foldeMap); private: // Argument allows user to specify a specific dialog to be raised @@ -183,6 +187,8 @@ private: bool _isOpen = false; bool _syncIsPaused = true; + bool _anySyncFolders = false; + std::unique_ptr _trayEngine; QPointer _contextMenu; QSharedPointer _trayWindow;